import { selector } from "recoil";
import {
  getProjectAllList,
  // getProjectPhaseTemplateAllList,
  getPhaseAllList,
  getProjectIssueAllList
} from "@services/index";

// 所有项目
export const fetchProjectAllList = selector({
  key: "getProjectAllList",
  get: async () => {
    const { data } = await getProjectAllList();
    return data.map((item:any)=>({
        ...item,
        label:item.name,
        value:item.id
    }));
  },
});
// 项目期数
export const fetchProjectIssueAllList = selector({
  key: "getProjectIssueAllList",
  get: async () => {
    const { data } = await getProjectIssueAllList();
    // data.unshift({id: '', name: '全部'});
    return data.map((item:any)=>({
        ...item,
        label:item.name,
        value:item.id
    }));
  },
});

// 阶段模板
export const fetchPhaseAllList = selector({
  key: "getPhaseAllList",
  get: async () => {
    const { data } = await getPhaseAllList();
    return data.map((item:any)=>({
        ...item,
        label:item.name,
        value:item.id
    }));
  },
});

// 所有阶段
// export const fetchProjectPhaseTemplateAllList = selector({
//   key: "fetchProjectPhaseTemplateAllList",
//   get: async () => {
//     const { data } = await getProjectPhaseTemplateAllList();
//     return data.map((item:any)=>({
//         ...item,
//         label:item.name,
//         value:item.id
//     }));
//   },
// });